package cn.itcast.crm.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import cn.itcast.crm.domain.Customer;

public interface CustomerDao extends JpaRepository<Customer, Integer> ,JpaSpecificationExecutor<Customer> {
	//未关联
	public List<Customer> findByFixedAreaIdIsNull();
	//已关联
	public List<Customer> findByFixedAreaId(String fixedAreaId);
	//修改关联
	@Query("update Customer set fixedAreaId = ? where id = ?")
	@Modifying
	public void updateFixedAreaId(String fixedAreaId,Integer id);
	public Customer findByTelephone(String telephone);
	@Query("update Customer set type=1 where telephone = ?")
	@Modifying
	public void updateType(String telephone);
	//查询用户
	public Customer findByTelephoneAndPassword(String telephone, String password);
	@Query("select fixedAreaId from Customer where address=?") 
	String findFixedAreaIdByAddress(String address);
}

